<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-row class="cu-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="4">
            <el-form-item label="校区品牌" prop="brand">
              <el-select v-model="query.brand" placeholder="">
                <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in brandOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="校区信息">
              <el-select v-model="query.campusId" clearable filterable placeholder="请选择校区" :loading="campusLoading" @focus="loadCampusOptions">
                <el-option v-for="item in campusOptions" :key="item.id" :label="item.fullName" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="订单来源" prop="orderSource">
              <el-select v-model="query.orderSource" placeholder="请选择" clearable required :style="{ width: '100%' }" filterable>
                <el-option v-for="item in orderSourceOptions" :key="item.enCode" :label="item.fullName" :value="item.enCode"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <template v-if="showAll">
            <el-col :span="6">
              <el-form-item label="订单类型" prop="orderType">
                <el-select v-model="query.orderType" placeholder="请选择" clearable required :style="{ width: '100%' }" filterable>
                  <el-option v-for="item in orderTypeOptions" :key="item.enCode" :label="item.fullName" :value="item.enCode"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <!--            <el-col :span="6">
              <el-form-item label="订单状态" prop="status">
                <el-select v-model="query.status" placeholder="请选择" clearable required :style="{ width: '100%' }"
                           filterable>
                  <el-option-group v-for="group in typeOptions" :key="group.id" :label="group.fullName">
                    <el-option v-for="item in group.children" :key="item.id" :label="item.fullName"
                               :value="item.enCode"></el-option>
                  </el-option-group>
                </el-select>
              </el-form-item>
            </el-col>-->
          </template>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()" native-type="submit">{{ $t('common.search') }}</el-button>
              <el-button icon="el-icon-refresh-right" @click="reset()">{{ $t('common.reset') }}</el-button>
              <el-button type="text" icon="el-icon-arrow-down" @click="showAll = true" v-if="!showAll">展开</el-button>
              <el-button type="text" icon="el-icon-arrow-up" @click="showAll = false" v-else>收起</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <div>
            <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()" v-has="'btn_add'">新增</el-button>
            <el-button type="text" icon="el-icon-download" @click="exportData()" v-has="'btn_download'">导出</el-button>
          </div>
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>

        <custom-table v-loading="listLoading" :data="list" :row-class-name="expandVisible">
          <el-table-column prop="shortName" label="校区名称" align="left" width="150" show-overflow-tooltip />
          <!-- <el-table-column prop="orderTitle" label="订单名称" align="left" width="200" show-overflow-tooltip /> -->
          <el-table-column prop="goodsName" label="商品名称" align="left" width="200" show-overflow-tooltip />
          <el-table-column prop="goodsCategoryName" label="商品类别" align="left" width="120" show-overflow-tooltip />
          <el-table-column prop="goodsTypeName" label="商品规格" align="left" width="120" show-overflow-tooltip />
          <el-table-column prop="price" label="单价" align="left" width="90" show-overflow-tooltip />
          <el-table-column prop="goodsNum" label="数量" align="left" width="80" show-overflow-tooltip />
          <el-table-column prop="description" label="商品备注" align="left" width="120" show-overflow-tooltip />
          <el-table-column prop="sendLogistics" label="是否发货" align="left" width="100" show-overflow-tooltip>
            <template slot-scope="scope">
              {{ scope.row.sendLogistics !== null ? (scope.row.sendLogistics == '1' ? '发货' : '不发货') : '' }}
            </template>
          </el-table-column>
          <el-table-column prop="orderNo" label="外部订单编号" align="left" width="120" show-overflow-tooltip />
          <el-table-column prop="createTime" label="下单时间" align="left" :formatter="custom.tableDateTimeFormat" width="120" show-overflow-tooltip />
          <el-table-column prop="orderSource" label="订单来源" align="left" width="100">
            <template slot-scope="scope">
              {{ scope.row.orderSource | dynamicCodeText(orderSourceOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="orderType" label="订单类型" align="left" width="80">
            <template slot-scope="scope">
              {{ scope.row.orderType | dynamicCodeText(orderTypeOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="payNo" label="支付编号" align="left" show-overflow-tooltip />
          <el-table-column prop="payTime" label="支付时间" align="left" :formatter="custom.tableDateTimeFormat" width="120" show-overflow-tooltip />
          <el-table-column prop="status" label="订单状态" align="left" width="80">
            <template slot-scope="scope">
              {{ scope.row.status | dynamicCodeText(orderStatusOptions) }}
            </template>
          </el-table-column>
          <!--          <el-table-column prop="status" label="订单状态" align="left" width="100" />-->
          <!--          <el-table-column label="操作" fixed="right" width="100">
            <template slot-scope="scope">
              <table-opts @edit="addOrUpdateHandle(scope.row.id)" @del="handleDel(scope.row.id)"></table-opts>
            </template>
          </el-table-column>-->
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <custom-form v-if="formVisible" ref="CustomForm" @refresh="refresh" />
  </div>
</template>
<script>
export { default } from './index.js'
</script>
